package com.hhkj.study.admin.order.excel;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.hhkj.study.admin.resource.excel.BaseExcelRes;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constant.Constants;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @Author luowu
 * @Date 2024/11/15 涵 14:05:23
 */
@Data
public class OrderItemExcelRes extends BaseExcelRes {

    /**
     * 购买者姓名
     */
    @NotBlank(message = "购买用户名不能为空")
    @Excel(name = "用户名", width = 20, needMerge = true, require = true)
    private String buyerName;

    /**
     * 购买者手机号
     */
    @Length(min = 11, max = 11, message = "手机号格式不正确")
    @NotBlank(message = "购买用户手机号不能为空")
    @Excel(name = "手机号", width = 20, needMerge = true, require = true)
    private String buyerMobile;

    /**
     * 是否企业，1企业0个人
     */
    @Excel(name = "是否企业订单", width = 20, needMerge = true, require = true, readConverterExp = "0=否,1=是", combo = {"是","否"} )
    private Integer enterpriseFlag;

    /**
     * 支付方式（微信wechat、支付宝alipay、扫二维码qrcode、对公转账bank，其他other）
     */
    @NotBlank(message = "支付方式不能为空")
    @Excel(name = "支付方式", width = 20, needMerge = true, require = true, readConverterExp = "wechat=微信,alipay=支付宝,qrcode=二维码,bank=对公转账,other=其他", combo = {"微信","支付宝","二维码","对公转账","其他"})
    private String payType;

    /**
     * 商品sku id
     * goodSkuCode 是为了通过名称查询商品skuId
     */
    @NotNull(message = "商品名不能有误")
    @Excel(name = "商品名", width = 20, needMerge = true, customDictType = Constants.GOODS_SKU_CODE, needFilterStr = StrUtil.DASHED, require = true)
    private Long goodsSkuId;

    /**
     * 原始价格
     */
    @NotNull(message = "原始价格不能为空")
    @Excel(name = "原始价格", width = 20, needMerge = true, require = true)
    private Integer originPrice;
    /**
     * 支付价格
     */
    @NotNull(message = "支付价格不能为空")
    @Excel(name = "支付价格", width = 20, needMerge = true, require = true)
    private Integer payPrice;

    /**
     * 支付时间
     */
    @NotNull(message = "支付时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @Excel(name = "支付时间", width = 20, needMerge = true, require = true)
    private Date payTime;

    /**
     * 销售姓名
     */
    @Excel(name = "销售", width = 20, needMerge = true)
    private String saleName;

    /**
     * 订单备注
     */
    @Excel(name = "备注", width = 20, needMerge = true)
    private String remark;

    @Override
    public String getTitle() {
        return "用户订单导入模板\n" +
                "1、表头红色加粗为必填字段\n" +
                "2、商品名格式:商品名-商品sku名,如二建协议通关班-建筑全科\n" +
                "3、用户手机号必须符合格式\n" +
                "4、时间格式为yyyy-MM-dd\n" +
                "5、付款金额必须整数\n";
    }

    @Override
    public String getSheetName() {
        return "用户订单导入模板";
    }
}
